package com.huawei.appmarket.framework.widget;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Path;
import android.util.AttributeSet;
import com.huawei.appgallery.foundation.ui.framework.widget.MaskImageView;
import o.dky.a;
import o.Logger;
import o.ewm$o;

public class RoundImageView extends MaskImageView {
    private int ʻ;
    private int ˊ;
    private int ˋ;
    private int ˏ;
    private boolean ᐝ;

    public RoundImageView(Context context) {
        this(context, null);
    }

    public RoundImageView(Context context, AttributeSet attributeSet) {
        this(context, attributeSet, 0);
    }

    public RoundImageView(Context context, AttributeSet attributeSet, int i) {
        int i2 = 0;
        super(context, attributeSet, i);
        this.ᐝ = true;
        if (attributeSet != null) {
            try {
                int dimensionPixelSize;
                TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, ewm$o.ﹺ, i, 0);
                if (obtainStyledAttributes.hasValue(ewm$o.ﾟॱ)) {
                    i2 = obtainStyledAttributes.getDimensionPixelSize(ewm$o.ﾟॱ, 0);
                }
                this.ˊ = obtainStyledAttributes.hasValue(ewm$o.ʻʼ) ? obtainStyledAttributes.getDimensionPixelSize(ewm$o.ʻʼ, i2) : i2;
                if (obtainStyledAttributes.hasValue(ewm$o.ʻʽ)) {
                    dimensionPixelSize = obtainStyledAttributes.getDimensionPixelSize(ewm$o.ʻʽ, i2);
                } else {
                    dimensionPixelSize = i2;
                }
                this.ˋ = dimensionPixelSize;
                if (obtainStyledAttributes.hasValue(ewm$o.ʹॱ)) {
                    dimensionPixelSize = obtainStyledAttributes.getDimensionPixelSize(ewm$o.ʹॱ, i2);
                } else {
                    dimensionPixelSize = i2;
                }
                this.ˏ = dimensionPixelSize;
                if (obtainStyledAttributes.hasValue(ewm$o.ʴ)) {
                    i2 = obtainStyledAttributes.getDimensionPixelSize(ewm$o.ʴ, i2);
                }
                this.ʻ = i2;
                this.ᐝ = obtainStyledAttributes.hasValue(ewm$o.ʻʻ) ? obtainStyledAttributes.getBoolean(ewm$o.ʻʻ, this.ᐝ) : this.ᐝ;
                obtainStyledAttributes.recycle();
            } catch (RuntimeException e) {
                Logger.e("RoundImageView", "RoundImageView init(AttributeSet attrs) " + e.toString());
            }
        }
    }

    public void setRadius(int i) {
        this.ʻ = i;
        this.ˏ = i;
        this.ˋ = i;
        this.ˊ = i;
        postInvalidate();
    }

    public void ˎ() {
        if (this.ᐝ) {
            this.ॱ = getResources().getDrawable(a.ˋˊ);
        } else {
            this.ॱ = null;
        }
    }

    protected void onDraw(Canvas canvas) {
        ˊ(canvas, getWidth(), getHeight());
        ˋ(canvas);
        super.onDraw(canvas);
    }

    protected void ˋ(Canvas canvas) {
    }

    public void ˊ(Canvas canvas, int i, int i2) {
        if (Math.min(i, i2) > Math.max(Math.max(this.ˊ, this.ˏ), Math.max(this.ˋ, this.ʻ))) {
            Path path = new Path();
            path.moveTo((float) this.ˊ, 0.0f);
            path.lineTo((float) (i - this.ˋ), 0.0f);
            path.quadTo((float) i, 0.0f, (float) i, (float) this.ˋ);
            path.lineTo((float) i, (float) (i2 - this.ʻ));
            path.quadTo((float) i, (float) i2, (float) (i - this.ʻ), (float) i2);
            path.lineTo((float) this.ˏ, (float) i2);
            path.quadTo(0.0f, (float) i2, 0.0f, (float) (i2 - this.ˏ));
            path.lineTo(0.0f, (float) this.ˊ);
            path.quadTo(0.0f, 0.0f, (float) this.ˊ, 0.0f);
            canvas.clipPath(path);
        }
    }
}
